What to use instead of if(isset($_POST['submit'])) for this.form.submit()?

Posted by paracaudex on Stack Overflow See other posts from Stack Overflow or by paracaudex
Published on 2010-03-20T15:58:31Z Indexed on 2010/03/20 16:01 UTC
Read the original article Hit count: 131

Filed under:
|
|

I want to run a particular block of PHP if the user submits a form. It works if I use a submit button with name="submit" and:

<?php
if(isset($_POST['submit'])) {
code to run
}
?>

I don't know anything about javascript, and I want the code to run if the user changes a dropdown menu. If I make the first line of the dropdown

<select name="dropdownname" onchange="this.form.submit()">

the form appears (I haven't tested it) to submit if the user changes the dropdown choice. However, if I do this, the if(isset($_POST['submit'])) PHP code doesn't run. Is there a PHP if statement I can write that will respond to the form being submitted even though it's being submitted by a change in the dropdown and not a submit button?

© Stack Overflow or respective owner

Related posts about dropdownlist

Related posts about JavaScript